package gov.kqqzyyy.monkey.orderpad.dialogFragment;

import android.app.DialogFragment;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import gov.kqqzyyy.monkey.orderpad.R;


/**
 * Created by Monkey on 2017/9/18.
 * 自定义progressDialog
 */
public class ProgressDialogFragment extends DialogFragment {

    TextView progressText;
    private String message;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        getDialog().setCancelable(false);
        getDialog().setCanceledOnTouchOutside(false);
        getDialog().setOnKeyListener((dialog, keyCode, event) -> keyCode == KeyEvent.KEYCODE_BACK);
        View dialogView = inflater.inflate(R.layout.dialog_progress, container, false);
        onBindDialogUI(dialogView);
        progressText.setText(message);
        return dialogView;
    }

    private void onBindDialogUI(View dialogView) {
        progressText = dialogView.findViewById(R.id.progress_dialog_message);
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
